/**
 * 轮滑出库管理管理初始化
 */
var Outbound = {
    id: "OutboundTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1,
};

/**
 * 初始化表格的列
 */
Outbound.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: 'id', field: 'id', visible: true, align: 'center', valign: 'middle'},
            {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
            {title: '尺码', field: 'type', visible: true, align: 'center', valign: 'middle'},
            {title: '颜色', field: 'color', visible: true, align: 'center', valign: 'middle'},
            {title: '数量', field: 'number', visible: true, align: 'center', valign: 'middle'},
            {title: '类型', field: 'level', visible: true, align: 'center', valign: 'middle'},
            {title: '出库日期', field: 'outTime', visible: true, align: 'center', valign: 'middle'},
            {title: '创建日期', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle',width:400}
    ];
};

/**
 * 检查是否选中
 */
Outbound.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        Outbound.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加轮滑出库管理
 */
Outbound.openAddOutbound = function () {
    var index = layer.open({
        type: 2,
        title: '添加轮滑出库管理',
        area: ['900px', '500px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/outbound/outbound_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看轮滑出库管理详情
 */
Outbound.openOutboundDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '轮滑出库管理详情',
            area: ['900px', '500px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/outbound/outbound_update/' + Outbound.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除轮滑出库管理
 */
Outbound.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/outbound/delete", function (data) {
            Feng.success("删除成功!");
            Outbound.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("outboundId",this.seItem.id);
        ajax.start();
    }
};


/**
 * 查询轮滑出库管理列表
 */
Outbound.search = function () {
    var queryData = {};
    queryData['name'] = $("#name").val();
    queryData['type'] = $("#type").val();
    queryData['color'] = $("#color").val();
    queryData['level'] = $("#level").val();
    Outbound.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = Outbound.initColumn();
    var table = new BSTable(Outbound.id, "/outbound/list", defaultColunms);
    table.setPaginationType("server");
   // table.setPagination(true);
    //table.setQueryParams(Outbound.formParams());
    Outbound.table = table.init();
});




